 //Initialize Select2 Elements
$(".select1").select2();



function commitApi(){
	var vForm = $("#infoDetail");
	validate.init(vForm,mind);
}

function mind(){
	getModal.show({content:'确定提交？',cb_l:cb});
}

function cb(){
	var dataStr = $("#infoDetail").serializeArray();
	var param = {};
    $.each(dataStr,function(i,v){
    	param[v.name] = v.value;
    })  
    console.log(param)
	$.ajax({
		url:'/api/updateApi',
		type:'POST',
		data:param,
	}).done(function(res){
		if(res.success){
			toast.show("更新成功");
		}else{
			toast.show(res.errorMsg);
		}
	}).fail(function(res){
		toast.show(res.errorMsg);
	})
	
}

function returnApi(){
	window.location = "./searchApi.html";
}

function addAttr(){
	var apiId=$("#id").val();
	var serviceName=$("#serviceName").val();
	if(apiId==''||apiId==null){
		toast.show("请先添加api");
		return ;
	}
	console.log(serviceName)
	window.location = "/api/addAttr?apiId="+apiId+"&serviceName="+serviceName;
}

function getArgs(args_id){  
	var pars=location.search;//获取当前url  
	var pos=pars.indexOf('?');//查找第一个?  
	if(pos==-1)  
	{  
		//	alert('参数为空!');  
		return;  
	}  
	else  
	pars=pars.substring(pos+1);//获取参数部分  
	var ps=pars.split("&");  
	var args=new Object();  
	var temp;  
	var name,value,index;  
	for(var i=0;i<ps.length;i++)  
	{  
		temp=ps[i];   
		index=temp.indexOf("=");  
		if(index==-1) continue;//如果参数中未包含=则继续  
		name=temp.substring(0,index);//参数名称  
		value=temp.substring(index+1);//参数的值  
		args[name]=value;  
	}  
	// return args;  
	for(var j in args)  
	if(args_id==j)  
	{  
		return args[j];  
	}  
}
serviceDiv();

